# var mongoose = require('mongoose');
# var databaseConfig = require('../config').database;
Mongoose = require 'mongoose'
Config = require '../config'
MongoConfig = Config.mongo
Logger = require('log4js').getLogger()




mongooseConOptions =
  server :
    poolSize : MongoConfig.poolSize


getMongooseConnection = (options) ->
  mongooseConnectStr = "mongodb://#{options.user}:#{options.pwd}@#{MongoConfig.host}:#{MongoConfig.port}/#{options.db}"
  Logger.info "mongooseConnectStr:#{mongooseConnectStr}"
  conn = Mongoose.createConnection mongooseConnectStr, mongooseConOptions, (err) ->
    if err
      Logger.error "mongoose error:#{err}"
  return conn


module.exports = 
  getMongooseConnection : getMongooseConnection
# Article = conn.model 'Article', require './schema/article'
# Reflection = conn.model 'Reflection', require './schema/reflection'
# RecommendArticle = conn.model 'RecommendArticle', require './schema/recommend_article'
# User = conn.model 'User', require './schema/user'
# Message = conn.model 'Message', require './schema/message'


# module.exports = 
#   Article : Article
#   Reflection : Reflection
#   RecommendArticle : RecommendArticle
#   User : User